package com.bfl.sa.sys.organization.service;

import com.bfl.sa.common.plugin.serivce.BaseTreeableService;
import com.bfl.sa.common.service.BaseService;
import com.bfl.sa.sys.organization.entity.Job;
import com.bfl.sa.sys.organization.mapper.JobMapper;
import com.google.common.collect.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Iterator;
import java.util.Set;


@Service
public class JobService extends BaseTreeableService<Job, Long> {

    /**
     * 过滤仅获取可显示的数据
     */
    public void filterForCanShow(Set<Long> jobIds, Set<Long[]> organizationJobIds) {

        Iterator<Long> iterator1 = jobIds.iterator();
        while (iterator1.hasNext()) {
            Long id = iterator1.next();
            Job o = findOne(id);
            if (o == null || Boolean.FALSE.equals(o.getShow())) {
                iterator1.remove();
            }
        }

        Iterator<Long[]> iterator2 = organizationJobIds.iterator();
        while (iterator2.hasNext()) {
            Long id = iterator2.next()[1];
            Job o = findOne(id);
            if (o == null || Boolean.FALSE.equals(o.getShow())) {
                iterator2.remove();
            }
        }

    }

}
